package com.myjavalab.core;

public class ExchangeRefrence {

	public static void main(String[] args) {
	
		Dog d1 = new Dog(1, "dog1");
		Dog d2 = new Dog(2, "dog2");
		Dog[] dogArray = {d1,d2};
		System.out.println(d1 +"," + d2);
		swap(dogArray,0,1);
		System.out.println(d1 +"," + d2);
	}
	
	public static void swap(Dog[] dogArray, int x, int y){
		Dog d = dogArray[x];
		dogArray[x] = dogArray[y];
		dogArray[y] = d;
	}
}

class Dog {
	int id;
	String name;

	public Dog(int id, String name) {
		this.id = id;
		this.name = name;
	}
	
	public String toString(){
		return id + name;
	}
}